import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;


public class RetriveFileFromByteArray {
	
	/**
	 * Writes the specified byte[] to the specified File path.
	 * 
	 * @param theFile File Object representing the path to write to.
	 * @param bytes The byte[] of data to write to the File.
	 * @throws IOException Thrown if there is problem creating or writing the 
	 * File.
	 */
	public RetriveFileFromByteArray(File theFile, byte[] bytes) throws IOException {
		  BufferedOutputStream bos = null;
		  
		  try {
		    FileOutputStream fos = new FileOutputStream(theFile);
		    bos = new BufferedOutputStream(fos); 
		    bos.write(bytes);
		  }finally {
		    if(bos != null) {
		      try  {
		        //flush and close the BufferedOutputStream
		        bos.flush();
		        bos.close();
		      } catch(Exception e){}
		    }
		  }
		  }
}
